<?php
namespace app\admin\controller;

use app\common\model\DistributeUser as DistributeUserModel;
use app\common\model\Exhibition as ExhibitionModel;
use app\common\model\Order as OrderModel;
use app\admin\tool\Parser;
use think\Db;
use think\Request;

class UserPurchase extends Base{

    /**
     * 采购的用户
     * 我的用户
     */
    public function index(){

        $this->data['title'] = '我的用户';
        $this->data['column'] = $this->column();

        $exhibition = ExhibitionModel::where('exhibition_time','>',time())->where('state',0)->order('exhibition_time desc')->find();

        //找到该客服的报名的信息
        $model = Db::table("distribute_user")->where("du.state = 0")->where('du.role = '.$this->admin->role)->where('du.admin_id = '.$this->admin->id)->where('e.exhibition_id = '.$exhibition['id'])->alias('du')->join('enroll e','du.user_id = e.user_id')->paginate(10);

        $this->data['model'] = $model;
        $this->data['parser'] = new Parser();

        return view("",$this->data);
    }

    protected function column(){
        return [
            'real_name'=>['name'=>'用户姓名','fun'=>'text','options'=>''],
            'mobile'=>['name'=>'用户手机号码','fun'=>'text','options'=>''],
            'province_name'=>['name'=>'省','fun'=>'text','options'=>''],
            'city_name'=>['name'=>'市','fun'=>'text','options'=>''],
            'district_name'=>['name'=>'区','fun'=>'text','options'=>''],
        ];
    }

}